package com.jp.algorithm.sort;

public class InsertSort {

    public static void sort(int[] a){
        for(int i=1;i<a.length;i++){
            int cur=a[i];
            int j=i;
            for(;j>0;j--){
                if(a[j-1]>cur){
                    a[j]=a[j-1];
                }else{
                    break;
                }
            }
            a[j]=cur;
        }
        print(a);
    }

    public static  void print(int[] a) {
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
    }

    public static void main(String[] args) {
        int[] a = {5,4,19,30,2};
        sort(a);

    }
}
